home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3514 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.9 KB

  1. Path: newsfeed.direct.ca!usenet
  2. From: qjackson@direct.ca
  3. Newsgroups: comp.lang.ada,comp.lang.c++,comp.lang.c,comp.lang.modula3,comp.lang.modula2,comp.lang.eiffel
  4. Subject: Re: Hungarian notation
  5. Date: Wed, 24 Jan 1996 15:46:14 GMT
  6. Organization: Parsepolis Software
  7. Message-ID: <4e5k6o$aci@grid.direct.ca>
  8. References: <30C40F77.53B5@swsbbs.com> <4cvu68$2jb@macaw.cyberport.com> <4d21og$iab@news.xmission.com> <4d2ok0$69s@beach.and.nl> <4dtv3gINNo9u@keats.ugrad.cs.ubc.ca>
  9. Reply-To: qjackson@direct.ca
  10. NNTP-Posting-Host: 204.174.249.41
  11. X-Newsreader: Forte Free Agent 1.0.82
  12.  
  13. c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) wrote:
  14.  
  15. >>    typedef char* empnm_t;
  16. >>    typedef char* beernm_t;
  17.  
  18. >Even that is going overboard. Someone will later see "empnm_t", and wonder what
  19. >the heck it is. If you mean "char *", just say "char *". The typedef operator
  20. >has its uses, but redefining simple types, like char * or int is not one of
  21. >them. The chief advantage is that you can use it with structs so that you can
  22. >eliminate having to write the struct keyword later on.
  23.  
  24. >I just wrote a 12000 line project that doesn't have one typedef in it (save for
  25. >automatically generated XDR definitions). The code is easy to read; I can go
  26. >back to it and understand precisely what is going on without hunting for nested
  27. >definitions.
  28.  
  29. I use typedef primarily if I know that an underlying data type might
  30. change at some point in the future, and I want to have one central way
  31. of changing it.  As in:
  32.  
  33. typedef unsigned int STRING_LENGTH;
  34.  
  35. STRING_LENGTH lenOfString (String& fooStr);
  36.  
  37. Should I later decide that I need long integers, I just change that
  38. one typedef, not a whole lot of unsigned int's.
  39.  
  40. Data abstraction.
  41.  
  42. Cheers,
  43.  
  44.  
  45.  
  46.  
  47. --                           
  48.                            | 
  49.     Parsepolis Software    |   Quinn Tyler Jackson
  50.         "ParseCity"        |     (aka 'Jamshid')
  51. >--------------------------|   qjackson@direct.ca
  52.                            |---------------------->
  53.  
  54.